package com.thiny.android.app.tnote.ui;

import java.util.Calendar;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.thiny.android.app.tnote.Constants;
import com.thiny.android.app.tnote.R;
import com.thiny.android.app.tnote.model.Note;

public class DetailActivity extends BaseActivity {

	private TextView dateTextView, titleTextView, contentTextView;
	private Note mNote;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.detail_layout);
		Intent intent = getIntent();
		mNote = (Note) intent.getSerializableExtra(Constants.EXTRA_NOTE);
		dateTextView = (TextView) findViewById(R.id.detail_note_date);
		titleTextView = (TextView) findViewById(R.id.detail_note_title);
		contentTextView = (TextView) findViewById(R.id.detail_note_content);
		setContent();
		findViewById(R.id.back).setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				finish();
			}
		});
	}

	private void setContent() {
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(mNote.getDate());
		dateTextView.setText("Date: " + calendar.get(Calendar.DAY_OF_MONTH));
		titleTextView.setText("Title: " + mNote.getTitle());
		contentTextView.setText("Content: " + mNote.getContent());
	}

}
